package com.mew.slots.core.game.jdqe.service;

import com.alibaba.fastjson.JSON;
import com.mew.common.entity.game.WinFree;
import com.mew.slots.core.common.game.BaseGameService;
import com.mew.slots.core.common.game.vo.BasePlayMsgs;
import com.mew.slots.core.common.messge.response.SlotsPlayResponseMessage;
import com.mew.slots.core.common.vo.StrategyGameVO;
import com.mew.slots.core.game.dwsl.bo.DwslInRoom;
import com.mew.slots.core.game.dwsl.bo.DwslInRoomList;
import com.mew.slots.core.game.dwsl.bo.DwslPlayMsgs;
import com.mew.slots.core.game.dwsl.message.DwslResponseMessage;
import com.mew.slots.core.game.dwsl.roller.DwslXml;
import com.mew.slots.core.game.dwsl.room.DwslRoom;
import com.mew.slots.core.game.jdqe.bo.JdqeInRoom;
import com.mew.slots.core.game.jdqe.bo.JdqePlayMsgs;
import com.mew.slots.core.game.jdqe.message.JdqeResponseMessage;
import com.mew.slots.core.game.jdqe.roller.JdqeIli;
import com.mew.slots.core.game.jdqe.roller.JdqeXml;
import com.mew.slots.core.game.jdqe.room.JdqeRoom;
import com.mew.slots.core.game.mjk.bo.MjkInRoom;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author Dylin
 */
@Service
@Slf4j
public class JdqeService extends BaseGameService {
    @Override
    public BasePlayMsgs startGame(StrategyGameVO player) {
        JdqeRoom room = new JdqeRoom();
        room.init(player.getRollerId(), JdqeIli.getInstance(),player.getWinFree().getFrees()>0,player.getInBetNumber(),player.getControlType());
        room.roundPlayIli();
        BasePlayMsgs res = room.getRes();
        if(res.getBouns() > 0){
            winFree.setJson(JSON.toJSONString(new JdqeInRoom()));
        }
        return res;
    }

    @Override
    public SlotsPlayResponseMessage myResp(WinFree winFree, BasePlayMsgs res) {
        JdqeResponseMessage message = new JdqeResponseMessage();
        JdqePlayMsgs pmres = (JdqePlayMsgs) res;

        message.setWns(pmres.getWns());
        message.setBonus(pmres.getBouns());
        winFree.setBounsType(pmres.getBouns());
        if(pmres.getBouns() == 1){
            winFree.setBounsNumber(10);
        }else if(pmres.getBouns() == 2){
            winFree.setBounsNumber(1);
        }
        return message;
    }
    @Override
    public void myAfterResp(SlotsPlayResponseMessage message,StrategyGameVO player, BasePlayMsgs res) { }
}
